var WebExcel;
(function (instance) {
    var init = function () {
        var {
            UniverCore,
            UniverDesign,
            UniverEngineRender,
            UniverEngineFormula,
            UniverDocs,
            UniverDocsUi,
            UniverUi,
            UniverSheets,
            UniverSheetsUi,
            UniverSheetsNumfmt,
            UniverSheetsFormula,
            UniverFacade,
        } = window

        var univer = new UniverCore.Univer({
            theme: UniverDesign.defaultTheme,
            locale: UniverCore.LocaleType.EN_US,
            locales: {
                [UniverCore.LocaleType.EN_US]: UniverUMD['en-US'],
            },
        });

        univer.registerPlugin(UniverEngineRender.UniverRenderEnginePlugin);
        univer.registerPlugin(UniverEngineFormula.UniverFormulaEnginePlugin);

        univer.registerPlugin(UniverUi.UniverUIPlugin, {
            container: "app",
        });

        univer.registerPlugin(UniverDocs.UniverDocsPlugin, {
            hasScroll: false,
        });
        univer.registerPlugin(UniverDocsUi.UniverDocsUIPlugin);

        univer.registerPlugin(UniverSheets.UniverSheetsPlugin);
        univer.registerPlugin(UniverSheetsUi.UniverSheetsUIPlugin);
        univer.registerPlugin(UniverSheetsNumfmt.UniverSheetsNumfmtPlugin);
        univer.registerPlugin(UniverSheetsFormula.UniverSheetsFormulaPlugin);

        let resources = new Array();
        for (let i = 0; i < 10; i++) {
            for (let j = 0; j < 10; j++) {
                resources.push(i + " --- " + j);
            }
        }
        let data = {
            "id": "1001",
            "name": "1001_sheet",
            "sheets": ["1001_sheet", "1002_sheet", "1003_sheet"],
            "resources": resources
        };

        univer.createUnit(UniverCore.UniverInstanceType.UNIVER_SHEET, data);

        const univerAPI = UniverFacade.FUniver.newAPI(univer);

        const activeSheet = univerAPI.getActiveWorkbook().getActiveSheet();

        const values = [
            ['Hello', 'World!'],
            ['Hello', 'Univer!'],
        ]
        const range = activeSheet.getRange(0, 0, values.length, values[0].length);
        if (!range) {
            throw new Error("Range not found");
        }
        range.setValues(values);
    }

    instance.init = init;
})(WebExcel || (WebExcel = {}));

var StringUtils = (function() {
    return {
        isEmpty: function(str) {
            return str === null || str === undefined || str.trim() === '';
        },
        isNotEmpty: function(str) {
            return !StringUtils.isEmpty(str);
        }
    }
})();
